package com.ifreshwing.activity.base;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ifreshwing.ainterface.Ipermissons;
import com.ifreshwing.bean.ReasonBean;
import com.ifreshwing.userpark.R;
import com.ifreshwing.view.CheckedTextView.CheckedTextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by lz on 2017/5/2.
 */

public class ReasonSelectActivity extends BaseActivity {
    @BindView(R.id.titleBar_back)
    ImageView titleBarBack;
    @BindView(R.id.titleBar_text)
    TextView titleBarText;
    @BindView(R.id.ll_next)
    LinearLayout llNext;
    @BindView(R.id.rl_select_reason)
    RelativeLayout rlSelectReason;
    @BindView(R.id.checkView)
    CheckedTextView checkView;
    List<ReasonBean.ResultBean> lst;
    @BindView(R.id.right_icon)
    ImageView rightIcon;

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reasonselect);
        ButterKnife.bind(this);
        titleBarText.setText("原因说明");
        titleBarBack.setVisibility(View.VISIBLE);
        checkView.showView(initData());
    }

    private List<ReasonBean.ResultBean> initData() {
        lst = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            ReasonBean.ResultBean bean = new ReasonBean.ResultBean();
            bean.setId(i + "");
            bean.setTag("停车原因停车原因" + i);
            lst.add(bean);
        }
        return lst;
    }

    @OnClick({R.id.titleBar_back, R.id.ll_next, R.id.rl_select_reason})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.titleBar_back:
                finish();
                break;
            case R.id.ll_next:
                ApplyPermisson(P_CAMERA, new Ipermissons() {
                    @Override
                    public void ps_CallBack(String[] permissionNames, int result) {

                    }

                    @Override
                    public void p_CallBack(String permissionName, int result) {

                    }
                });
                break;
            case R.id.rl_select_reason:
                checkView.setVisibility(checkView.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
                rightIcon.setImageResource(checkView.getVisibility() == View.VISIBLE ? R.mipmap.down : R.mipmap.right);
                break;
        }
    }


}
